package com.visualize.demo.repository;

import com.visualize.demo.model.Place;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface PlaceRepository extends CrudRepository<Place, Integer> {
    @Query(value =
            "select id,time,anhui,aomen,beijing,fujian,gansu,guangdong,guangxi,guizhou,hainan," +
                    "hebei,henan,heilongjiang,hubei,hunan,jilin,jiangsu,jiangxi,liaoning,neimenggu,ningxia," +
                    "qinghai,shandong,shanxi,shannxi,shanghai,sichuan,taiwan,tianjin,xizang,xianggang," +
                    "xinjiang,yunnan,zhejiang,chongqing " +
                    "from place " +
                    "where time between :start_time and :end_time", nativeQuery = true)
    List<Place> getPlacesByTime(@Param("start_time") Date start_time, @Param("end_time") Date end_time);
}
